package task06_05;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/5/4 9:12
 * @description:
 */
public class CopyFileTry {
  public static void main(String[] args) {
    BufferedReader bufferedReader=null;
    BufferedWriter bufferedWriter=null;
    try{
      bufferedReader=new BufferedReader(new FileReader("a.txt"));
      bufferedWriter=new BufferedWriter(new FileWriter("c:\\a.txt"));
      String line=null;
      while ((line=bufferedReader.readLine())!=null){
        bufferedWriter.write(line);
        bufferedWriter.newLine();
        bufferedWriter.flush();
      }
    }catch (Exception e){
      System.out.println(e.getMessage());
    }finally {
     if(bufferedReader!=null){
       try {
         bufferedReader.close();
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
      if(bufferedWriter!=null){
        try {
          bufferedWriter.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
}
